home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / Libraries / C Internet Config / IC Read Only ƒ / __Build Fat Component.r next >
Encoding:
Text File  |  1995-11-17  |  7.9 KB  |  189 lines  |  [TEXT/SPM ]

  1. #include <MixedMode.r>
  2. #include <FatRSRC.r>
  3.  
  4. #define FAT            1
  5. #define SAFE        1
  6. #define SAFER        1
  7. #define CURRENTISA    0
  8. #define SHRINKING    1
  9.  
  10. #define ResType            'CODE'                    //    Change to the type of resource you wish to create
  11. #define ResID            300                        //    Change to the ID of resource you wish to create
  12. #define ResName            "Fat IC ReadOnly Code"
  13.  
  14. #define PPCResFile        "Fat IC Generic Override.π.rsrc"    //    Change to the name of this project's resource file
  15. #define PPCProcInfo        $000003F0                //    Change to ProcInfo value for your resource's PowerPC code
  16.  
  17. #define M68KResFile        "68k ICRO.rsrc"            //    If FAT, Change to name of the file to merge a 68K resource from
  18. #define M68KResType    'CODE'                    //    If FAT, Change to the type of 68K resource to merge in
  19. #define M68KResID        300                        //    If FAT, Change to the ID of 68K resource to merge in
  20. #define M68KProcInfo    $0                        //    Change to ProcInfo value for your fat resource's 68K code
  21.  
  22. /*
  23.     Prepend a routine descriptor (from a 'rdes', 'fdes', 'Fdes', 'sdes', 'Sdes', 'ades', 'Ades' or
  24.     '<des' template) to our temporary resource and store it into a resource with the type and ID
  25.     specified by ResType and ResID.
  26.     
  27.     •    Change the ResType and ResID macros to the resource type and ID you wish to create.
  28.     
  29.     •    Change the PPCResFile macro to the name of this project's resource file.  
  30.  
  31.     •    Change the PPCProcInfo macro to the ProcInfo value for your resource's PowerPC code.  
  32.  
  33.     •    If creating a "Fat" code resource, change the M68KResFile macro to the name of the file to
  34.         merge a 68K resource from.  
  35.  
  36.     •    If creating a "Fat" code resource, change the M68KResType and M68KResID macros to the
  37.         resource type and ID of a 68K resource to merge in.
  38.  
  39.     •    If creating a "Fat" code resource, change the M68KProcInfo macro to the ProcInfo value for
  40.         your 68K code.  
  41.     
  42.     
  43.     Accelerated (native PowerPC) Code Resource ('rdes' template) :
  44.     
  45.     Set FAT to 0 to build an accelerated (native PowerPC) code resource with the 'rdes' template.
  46.     Resources created with this template can be executed on a PowerMac from either PowerPC or
  47.     68K mode.  Calling the resource from 68K code (in emulation) will cause a mode switch.
  48.     Resources created with this template are unusable on 68K Macs.
  49.     
  50.     Fat Code Resource ('fdes' template) :
  51.     
  52.     Set FAT to 1, SAFE to 0, and CURRENTISA to 0 to build a "Fat" code resource with the 'fdes'
  53.     template.  If a resource created with this template is used on a 68K Mac, the 68K portion of the
  54.     code resource will be executed.  If it's used on a PowerMac, the PowerPC portion of the code
  55.     resource will be executed.  You would use this template if, when running on a PowerMac in 68K
  56.     emulation, there is less overhead switching to PowerPC mode and executing your PowerPC code
  57.     than executing your 68K code.  Resources created with this template require the Mixed Mode
  58.     Manager to run on a 68K Mac.
  59.     
  60.     Fat Code Resource dependant on current mode ('Fdes' template) :
  61.     
  62.     Set FAT to 1, SAFE to 0, and CURRENTISA to 1 to build a "Fat" code resource, which is dependant
  63.     on the current mode, with the 'Fdes' template.  Code resources created with this template will
  64.     minimize mode switches by executing your PowerPC code if called by PowerPC code (not in 68K
  65.     emulation), and executing your 68K code if called in emulation (or on a 68K Mac).  You would use
  66.     this template if, when running on a PowerMac in 68K emulation, there is less overhead executing
  67.     your 68K code than switching modes and executing your PowerPC code.  Only use this template if
  68.     your code resource, when running on a PowerMac, might be executed by either 68K or PowerPC
  69.     code.  Resources created with this template require the Mixed Mode Manager to run on a 68K Mac.
  70.     
  71.     Safe Fat Code Resource ('sdes' template) :
  72.     
  73.     Set FAT to 1, SAFE to 1, SAFER to 0, SHRINKING to 0, and CURRENTISA to 0 to build a "Safe
  74.     Fat" code resource with the 'sdes' template.  Code resources created with this template are
  75.     similar to those created by the 'fdes' template (described above), but will run on a 68K Mac
  76.     with or without the Mixed Mode Manager.
  77.     
  78.     Safe Fat Code Resource dependant on current mode ('Sdes' template) :
  79.     
  80.     Set FAT to 1, SAFE to 1, SAFER to 0, SHRINKING to 0, and CURRENTISA to 1 to build a "Safe
  81.     Fat" code resource, which is dependant on the current mode, with the 'Sdes' template.  Code
  82.     resources created with this template are similar to those created with the 'Fdes' template
  83.     (described above), but will run on a 68K Mac with or without the Mixed Mode Manager.
  84.  
  85.     Safer Fat Code Resource ('ades' template) :
  86.     
  87.     Set FAT to 1, SAFE to 1, SAFER to 1, SHRINKING to 0, and CURRENTISA to 0 to build a "Safer
  88.     Fat" code resource with the 'ades' template.  Code resources created with this template are
  89.     similar to those created with the 'sdes' template (described above).  The 'sdes' template was
  90.     inherited from MPW.  We provide a "Safer" code resource template to work around some
  91.     potential problems with the 'sdes' template.  Code resources created with this template support
  92.     register-based calling conventions, and 68K Macs without instruction caches.
  93.     
  94.     Safer Fat Code Resource dependant on current mode ('Ades' template) :
  95.     
  96.     Set FAT to 1, SAFE to 1, SAFER to 1, SHRINKING to 0, and CURRENTISA to 1 to build a "Safer
  97.     Fat" code resource, which is dependant on the current mode, with the 'Ades' template.  Code
  98.     resources created with this template are similar to those created with the 'Sdes' template
  99.     (described above), but works around some potential problems with it.  Code resources created
  100.     with this template supports register-based calling conventions, and 68K Macs without
  101.     instruction caches.
  102.     
  103.     Shrinking Safe Fat Code Resource ('<des' template) :
  104.     
  105.     Set FAT to 1, SAFE to 1, and SHRINKING to 1 to create a "Shrinking Safe Fat" code resource
  106.     with the '<des' template.  You would use this template if, when running on a PowerMac in
  107.     68K emulation, there is less overhead switching to PowerPC mode and executing your
  108.     PowerPC code than executing your 68K code.  This resource will determine what type of Mac
  109.     you are using.  If you are using a 68K Mac, the PowerPC code will be truncated from the end
  110.     of the resource in memory.  If you are using a PowerMac, the PowerPC code will be moved to
  111.     the start of the resource, and the left-over space will be truncated from the end of the
  112.     resource in memory.  This type of resource will run natively to either platform, and will not
  113.     keep unused code in memory.
  114.     
  115.     
  116. !!!    Beware, the 68K register A0 will not point to the start of your resource upon entry.  Some
  117. !!!    68K code resources rely on this.  For example, many INIT's pass A0 to RecoverHandle, to get a
  118. !!!    Handle to their code, to detach it (with DetachResource) from its resource file.  Instead, INIT's
  119. !!!    should use Get1Resource to get this Handle.
  120. !!!
  121. !!!    The SetUpA4-related routines will work properly in the 68K code of a "Fat" resource.
  122.     
  123.     • This file does not set any resource attributes for your code resource.  You must specify your
  124.     resource attributes below (ala Rez), or set them once your resource is built, with ResEdit.
  125.     
  126.     • To create your code resource, simply bring this project up to date.  You do not need to
  127.     generate a target.  Your code resource will be saved to your project's resource file.
  128.  
  129.     • This file must be compiled AFTER "_CopyToResource.r"
  130.     
  131.     Colen Garoutte-Carson
  132.     Symantec Corp.
  133. */
  134.  
  135. #if FAT
  136.     #if SAFE
  137.         #if SHRINKING
  138.             type ResType as '<des';
  139.         #else
  140.             #if SAFER
  141.                 #if CURRENTISA
  142.                     type ResType as 'Ades';
  143.                 #else
  144.                     type ResType as 'ades';
  145.                 #endif
  146.             #else
  147.                 #if CURRENTISA
  148.                     type ResType as 'Sdes';
  149.                 #else
  150.                     type ResType as 'sdes';
  151.                 #endif
  152.             #endif    
  153.         #endif
  154.     #else
  155.         #if CURRENTISA
  156.             type ResType as 'Fdes';
  157.         #else
  158.             type ResType as 'fdes';
  159.         #endif
  160.     #endif
  161. #else
  162.     type ResType as 'rdes';
  163. #endif
  164.  
  165. resource ResType (ResID,ResName) {
  166. #if FAT
  167.     #if SAFE
  168.         #if !SHRINKING
  169.             M68KProcInfo,
  170.             PPCProcInfo,
  171.         #endif
  172.     #else
  173.         M68KProcInfo,
  174.         PPCProcInfo,
  175.     #endif
  176. #else    
  177.     PPCProcInfo,
  178. #endif
  179. #if FAT
  180.     $$Resource(M68KResFile, M68KResType, M68KResID),
  181.     #if SAFE
  182.         #if SHRINKING
  183.             PPCProcInfo,
  184.         #endif
  185.     #endif
  186. #endif
  187.     $$Resource(PPCResFile, 'TEMP', 0)
  188. };
  189.